package com.xiangge.zuoye;

import java.util.Scanner;

public class Demo7 {
    public static void main(String[] args) {
        System.out.println("请输入一个正小数：");
        double x = new Scanner(System.in).nextDouble();
        if (x<=0){
            System.err.println("数据不合法");

        }
        int x1 = getZhengshu(x);
        System.out.println("四舍五入为：" + x1);
    }

    public static int getZhengshu(double x) {

        int a = 0;
        int shifenwei = (int) ((x * 10) % 10);
        if (shifenwei<5){
            a = (int)x;
        }else {
            a = (int)(x+1);
        }
        return a;
    }
}
